package qf.pojo;

/**
 * @author 86198
 * @version V1.0
 * @Project Java_qf
 * @Package qf.pojo
 * @Description:
 * @Date 2022/5/27 14:50
 */
public class Page {
    //    页码，当前页数
    private Integer pageIndex;
    //    每页呈现的多少条数据
    private Integer pageSize;
    //    总数据条数
    private Integer totalCounts;
    //    总页数
    private Integer totalPages;
    //    查询数据的起始索引
    private Integer startPages;

    public Page() {}

    public Page(Integer pageIndex, Integer pageSize) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;

        this.startPages=(pageIndex - 1) * pageSize;

    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalCounts() {
        return totalCounts;
    }

    public void setTotalCounts(Integer totalCounts) {
        this.totalCounts = totalCounts;
        this.setTotalPages(totalCounts %pageSize == 0 ? totalCounts/pageSize : totalCounts/pageSize + 1);
    }

    public Integer getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }

    public Integer getStartPages() {
        return startPages;
    }

    public void setStartPages(Integer startPages) {
        this.startPages = startPages;
    }

    @Override
    public String toString() {
        return "Page{" +
                "pageIndex=" + pageIndex +
                ", pageSize=" + pageSize +
                ", totalCounts=" + totalCounts +
                ", totalPages=" + totalPages +
                ", startPages=" + startPages +
                '}';
    }

}
